package system.student.funtion.exhibition.teacherfunction.impl;

import system.student.entity.Course;
import system.student.entity.Score;
import system.student.entity.StudentDetail;
import system.student.entity.user.Student;
import system.student.funtion.exhibition.teacherfunction.CourseService;
import system.student.mapper.CourseMapper;
import system.student.util.LogRecordUtil;
import system.student.util.MapperUtil;

import java.util.List;

public class CourseServiceImpl implements CourseService {

    //  注入courseMapper
    private CourseMapper courseMapper = MapperUtil.getMapper(CourseMapper.class);

    /**
     * 获取所有课程
     * @param teacherId
     * @return
     */
    @Override
    public List<Course> findAllCourseByTeacherId(Long teacherId) {
        List<Course> courseList = courseMapper.findAllCourse(teacherId);
        return courseList;
    }

    /**
     * 获取所有学生
     * @param courseId
     * @return
     */
    @Override
    public List<Student> findAllStudentByCourseId(Long courseId) {
        List<Student> studentList = courseMapper.findAllStudent(courseId);
        return studentList;
    }

    /**
     * 添加课程
     * @param course
     */
    @Override
    public void addCourse(Course course) {
        CourseMapper courseMapperProxy = LogRecordUtil.wrap(courseMapper, CourseMapper.class);
        courseMapperProxy.addCourse(course);
    }

    /**
     * 添加成绩
     * @param  studentScore
     */
    @Override
    public void updateScore(Score studentScore) {
        courseMapper.updateScore(studentScore);
    }

    /**
     * 通过课程id和学生id查询某个学生信息
     * @param studentScore
     * @return
     */
    @Override
    public List<StudentDetail> findStudentById(Score studentScore) {
        return courseMapper.findStudentById(studentScore);
    }

    /**
     * 通过课程id查询所有学生id
     * @param courseId
     */
    @Override
    public List<Student> findAllStudentIDAndNameByCourseId(Long courseId) {
        List<Student> studentIdList= courseMapper.findAllStudentIDAndNameByCourseId(courseId);
        return studentIdList;
    }


}
